package com.zhang.cicadatravels.main.search;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.ArrayList;

/**
 * Created by dllo on 16/6/23.
 */
public class SearchAdapter extends FragmentPagerAdapter {
    private ArrayList<Fragment> fragments;
    private Context context;
    String[] titles = {"国外", "国内", "四季"};

    public void setFragments(ArrayList<Fragment> fragments) {

        this.fragments = fragments;
        notifyDataSetChanged();
    }

    public SearchAdapter(FragmentManager fm, Context context) {
        super(fm);
        this.context = context;
    }

    public SearchAdapter(FragmentManager fm) {
        super(fm);

    }


    @Override
    public Fragment getItem(int position) {
        return fragments == null ? null : fragments.get(position);
    }

    @Override
    public int getCount() {
        return fragments == null ? 0 : fragments.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titles[position];
    }
}
